/********************************************************
* @file: IMO3D.h
* @date: 09/09/2009
********************************************************
* acmFrame
********************************************************/


#ifndef _IMO3D_H_
#define _IMO3D_H_


// includes
//----------
#include "./geometry/curves/curve.h"
#include "./geometry/box3d.h"
#include "./geometry/point3d.h"
#include "./draw.h"
#include <vector>

// macro to call the singleton mgControl
//---------------------------------------
#define IMO IMO3D::instance()


/*!
* CLASS
* IMO3D
*
* Collector of geometric objects. 
*
* @version 5.00 $Date: 15/02/2000 $
*/
class IMO3D
{

public:

  // @brief accesses the singleton object.
  static IMO3D& instance();


protected:

  // @brief default constructor.
  IMO3D();

  // @brief destructor.
  virtual ~IMO3D();


public:

  void setEndAction (void *obj, void (*endAction)(void *obj, Curve *cv, int _idSurf));
  void setDrawCurve (drawGRA *_obj);

  int beginCreate       (char *_type);
  int beginCreate       (char *_type, const vector<Point3D>& _addp);
  int beginCreate       (char *_type, double _x, double _y,double _z);
  int addTempPoint      (double _x, double _y,double _z);
  int addTempOrthoPoint (double _x, double _y,double _z);
  Point3D getLastTempPoint  ( );
  int addPoint          (double _x, double _y,double _z);
  int endAddPoint       ();

  Curve* getCurrCurve();

  void releaseCurrCurve();

  void drawCurrCurve();

  bool isActive()
  {
    if( m_currCurve != NULL )
      return true;
    return false;
  }
  void initialize()
  {
    m_initializationStatus = true;
  }
  bool isInitialized()
  {
	  return m_initializationStatus;
  }
  void setSurfaceId(int id)
  {
	  m_idSurf = id;
  }
  int getSurfaceId()
  {
	  return m_idSurf;
  }
  bool WasSurfaceDefined()
  {
	  return  m_idSurf>=0;
  }

private:
  // pointer to the SINGLETON object of this class.
  static IMO3D* m_imo3d;
  bool m_initializationStatus;
  int m_idSurf;

  drawGRA     *m_objdraw;
  Curve       *m_currCurve;
  void        *m_objClass;

  // current temporary pts
  double      xtmp, ytmp, ztmp;

  void       (*m_endAction) (void *m_objClass, Curve *cv, int _idSurf);

};

#endif // _IMO3D_H_
